package com.example.administrator.printoutindemo;

import android.content.Context;


import com.example.administrator.printoutindemo.database.SQLiteDBService;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class Outstorage implements Serializable {

	private String _out_storage_time;
	private String _out_storage_count;
	private String _receive_address;
	private String _receive_username;
	private String _unit;

	private SQLiteDBService sqliteDBservice;

	public Outstorage() {

	}

	public Outstorage(Context context) {
		sqliteDBservice = new SQLiteDBService(context);
	}

	// 将JSON对象转化为list
	public List<Outstorage> getListFromJSON(String JsonStr) {
		List<Outstorage> clist = new ArrayList<Outstorage>();

		try {

			JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

			for (int i = 0; i < jay.length(); i++) {
				JSONObject temp = (JSONObject) jay.get(i);

				Outstorage n = new Outstorage();

				n.set_out_storage_count(temp.getString("out_storage_count"));
				n.set_out_storage_time(temp.getString("out_storage_time"));
				n.set_receive_address(temp.getString("receive_address"));
				n.set_receive_username(temp.getString("receive_username"));
				n.set_unit(temp.getString("unit"));

				clist.add(n);

			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return clist;

	}

	public String get_out_storage_time() {
		return _out_storage_time;
	}

	public void set_out_storage_time(String _out_storage_time) {
		this._out_storage_time = _out_storage_time;
	}

	public String get_out_storage_count() {
		return _out_storage_count;
	}

	public void set_out_storage_count(String _out_storage_count) {
		this._out_storage_count = _out_storage_count;
	}

	public String get_receive_address() {
		return _receive_address;
	}

	public void set_receive_address(String _receive_address) {
		this._receive_address = _receive_address;
	}

	public String get_receive_username() {
		return _receive_username;
	}

	public void set_receive_username(String _receive_username) {
		this._receive_username = _receive_username;
	}

	public String get_unit() {
		return _unit;
	}

	public void set_unit(String _unit) {
		this._unit = _unit;
	}

}